﻿using System;
using System.ComponentModel;
using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace Data.MappingClasses
{
    [TableAttribute(Name = "dbo.StreetType")]
    public partial class StreetType : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private short _idStreetType;

        private string _nameStreetType;

        private EntitySet<Street> _Streets;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(ChangeAction action);
        partial void OnCreated();
        partial void OnidStreetTypeChanging(short value);
        partial void OnidStreetTypeChanged();
        partial void OnnameStreetTypeChanging(string value);
        partial void OnnameStreetTypeChanged();
        #endregion

        public StreetType()
        {
            this._Streets = new EntitySet<Street>(AttachStreets, DetachStreets);
            OnCreated();
        }

        [ColumnAttribute(Storage = "_idStreetType", AutoSync = AutoSync.OnInsert, DbType = "SmallInt NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
        public short idStreetType
        {
            get
            {
                return this._idStreetType;
            }
            set
            {
                if ((this._idStreetType != value))
                {
                    this.OnidStreetTypeChanging(value);
                    this.SendPropertyChanging();
                    this._idStreetType = value;
                    this.SendPropertyChanged("idStreetType");
                    this.OnidStreetTypeChanged();
                }
            }
        }

        [ColumnAttribute(Storage = "_nameStreetType", DbType = "VarChar(75) NOT NULL", CanBeNull = false)]
        public string nameStreetType
        {
            get
            {
                return this._nameStreetType;
            }
            set
            {
                if ((this._nameStreetType != value))
                {
                    this.OnnameStreetTypeChanging(value);
                    this.SendPropertyChanging();
                    this._nameStreetType = value;
                    this.SendPropertyChanged("nameStreetType");
                    this.OnnameStreetTypeChanged();
                }
            }
        }

        [AssociationAttribute(Name = "StreetType_Street", Storage = "_Streets", ThisKey = "idStreetType", OtherKey = "refStreetType")]
        public EntitySet<Street> Streets
        {
            get
            {
                return this._Streets;
            }
            set
            {
                this._Streets.Assign(value);
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private void AttachStreets(Street entity)
        {
            this.SendPropertyChanging();
            entity.StreetType = this;
        }

        private void DetachStreets(Street entity)
        {
            this.SendPropertyChanging();
            entity.StreetType = null;
        }
        public override string ToString()
        {
            return nameStreetType;
        }
    }
}